<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of gssm_speech_linear</title>
  <meta name="keywords" content="gssm_speech_linear">
  <meta name="description" content="GSSM_SPEECH  Generalized state space model for single phoneme speech enhancement">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../../menu.html">Home</a> &gt;  <a href="#">ReBEL-0.2.7</a> &gt; <a href="#">examples</a> &gt; <a href="#">gssm</a> &gt; gssm_speech_linear.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../../menu.html"><img alt="<" border="0" src="../../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="menu.html">Index for .\ReBEL-0.2.7\examples\gssm&nbsp;<img alt=">" border="0" src="../../../right.png"></a></td></tr></table>-->

<h1>gssm_speech_linear
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="box"><strong>GSSM_SPEECH  Generalized state space model for single phoneme speech enhancement</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="box"><strong>function [varargout] = model_interface(func, varargin) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> GSSM_SPEECH  Generalized state space model for single phoneme speech enhancement

 A single speech phoneme sampled at 8kHz is corrupted by additive colored (pink) noise.
 We use a simple linear autoregressive model (10th order) to model the generative model
 of the speech signal.
 We model the pink noise by a known 6th order linear autoregressive process driven by white Gaussian
 noise with known variance. The SNR of the noisy signal (y=clean+noise) is 0dB.

 The colored noise modeling (augmented state space model) is done according to the method proposed in:
 &quot;Filtering of Colored Noise for Speech Enhancment and Coding&quot;, by J. D. Gibson, B. Koo and S. D. Gray,
 IEEE Transactions on Signal Processing, Vol. 39, No. 8, August 1991.

   Copyright (c) Oregon Health &amp; Science University (2006)

   This file is part of the ReBEL Toolkit. The ReBEL Toolkit is available free for
   academic use only (see included license file) and can be obtained from
   http://choosh.csee.ogi.edu/rebel/.  Businesses wishing to obtain a copy of the
   software should contact rebel@csee.ogi.edu for commercial licensing information.

   See LICENSE (which should be part of the main toolkit distribution) for more
   detail.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../../matlabicon.gif)">
<li><a href="../../.././ReBEL-0.2.7/core/consistent.html" class="code" title="function errstring = consistent(ds, type)">consistent</a>	CONSISTENT   Check ReBEL data structures for consistentency.</li><li><a href="../../.././ReBEL-0.2.7/core/gennoiseds.html" class="code" title="function NoiseDS = gennoiseds(ArgDS)">gennoiseds</a>	GENNOISEDS    Generates a NoiseDS data structure describing a noise source.</li></ul>
This function is called by:
<ul style="list-style-image:url(../../../matlabicon.gif)">
<li><a href="../../.././ReBEL-0.2.7/examples/dual_estimation/demspeech_dual.html" class="code" title="">demspeech_dual</a>	DEMSPEECH_DUAL  Sigma-Point Kalman Filter based Speech Enhancement Demonstration.</li></ul>
<!-- crossreference -->

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<ul style="list-style-image:url(../../../matlabicon.gif)">
<li><a href="#_sub1" class="code">function model = init(init_args)</a></li><li><a href="#_sub2" class="code">function model = setparams(model, params, index_vector)</a></li><li><a href="#_sub3" class="code">function new_state = ffun(model, state, V, U1)</a></li><li><a href="#_sub4" class="code">function observ = hfun(model, state, N, U2)</a></li></ul>
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="fragment"><pre>0001 <span class="comment">% GSSM_SPEECH  Generalized state space model for single phoneme speech enhancement</span>
0002 <span class="comment">%</span>
0003 <span class="comment">% A single speech phoneme sampled at 8kHz is corrupted by additive colored (pink) noise.</span>
0004 <span class="comment">% We use a simple linear autoregressive model (10th order) to model the generative model</span>
0005 <span class="comment">% of the speech signal.</span>
0006 <span class="comment">% We model the pink noise by a known 6th order linear autoregressive process driven by white Gaussian</span>
0007 <span class="comment">% noise with known variance. The SNR of the noisy signal (y=clean+noise) is 0dB.</span>
0008 <span class="comment">%</span>
0009 <span class="comment">% The colored noise modeling (augmented state space model) is done according to the method proposed in:</span>
0010 <span class="comment">% &quot;Filtering of Colored Noise for Speech Enhancment and Coding&quot;, by J. D. Gibson, B. Koo and S. D. Gray,</span>
0011 <span class="comment">% IEEE Transactions on Signal Processing, Vol. 39, No. 8, August 1991.</span>
0012 <span class="comment">%</span>
0013 <span class="comment">%   Copyright (c) Oregon Health &amp; Science University (2006)</span>
0014 <span class="comment">%</span>
0015 <span class="comment">%   This file is part of the ReBEL Toolkit. The ReBEL Toolkit is available free for</span>
0016 <span class="comment">%   academic use only (see included license file) and can be obtained from</span>
0017 <span class="comment">%   http://choosh.csee.ogi.edu/rebel/.  Businesses wishing to obtain a copy of the</span>
0018 <span class="comment">%   software should contact rebel@csee.ogi.edu for commercial licensing information.</span>
0019 <span class="comment">%</span>
0020 <span class="comment">%   See LICENSE (which should be part of the main toolkit distribution) for more</span>
0021 <span class="comment">%   detail.</span>
0022 
0023 <span class="comment">%===============================================================================================</span>
0024 <a name="_sub0" href="#_subfunctions" class="code">function [varargout] = model_interface(func, varargin)</a>
0025 
0026   <span class="keyword">switch</span> func
0027 
0028     <span class="comment">%--- Initialize GSSM data structure --------------------------------------------------------</span>
0029     <span class="keyword">case</span> <span class="string">'init'</span>
0030       model = <a href="#_sub1" class="code" title="subfunction model = init(init_args)">init</a>(varargin);
0031         error(<a href="../../.././ReBEL-0.2.7/core/consistent.html" class="code" title="function errstring = consistent(ds, type)">consistent</a>(model,<span class="string">'gssm'</span>));               <span class="comment">% check consistentency of initialized model</span>
0032       varargout{1} = model;
0033 
0034     <span class="comment">%--------------------------------------------------------------------------------------------</span>
0035     <span class="keyword">otherwise</span>
0036 
0037       error([<span class="string">'Function '''</span> func <span class="string">''' not supported.'</span>]);
0038 
0039   <span class="keyword">end</span>
0040 
0041 
0042 <span class="comment">%===============================================================================================</span>
0043 <a name="_sub1" href="#_subfunctions" class="code">function model = init(init_args)</a>
0044 
0045 
0046   load speech_data.mat noise_model noise_pnvar noisy clean;    <span class="comment">% Loads colored noise model (LPC parameters) and process noise variance</span>
0047 
0048   speech_taps = 10;
0049   speech_model = aryule(clean,speech_taps);
0050   speech_pnvar = var(filter(speech_model,1,clean));
0051   speech_model = -1*speech_model(2:end);
0052   noise_taps  = length(noise_model);     <span class="comment">% number of noise filter taps</span>
0053 
0054   <span class="comment">%-- REQUIRED FIELDS</span>
0055 
0056   model.type = <span class="string">'gssm'</span>;                  <span class="comment">% object type = generalized state space model</span>
0057   model.tag  = <span class="string">'GSSM_Speech_Colored_Noise_Linear'</span>;  <span class="comment">% ID tag</span>
0058 
0059   model.ffun       = @<a href="#_sub3" class="code" title="subfunction new_state = ffun(model, state, V, U1)">ffun</a>;             <span class="comment">% functionhandle to FFUN</span>
0060   model.hfun       = @<a href="#_sub4" class="code" title="subfunction observ = hfun(model, state, N, U2)">hfun</a>;             <span class="comment">% functionhandle to HFUN</span>
0061   model.setparams  = @<a href="#_sub2" class="code" title="subfunction model = setparams(model, params, index_vector)">setparams</a>;        <span class="comment">% functionhandle to SETPARAMS</span>
0062 
0063   model.statedim   = speech_taps + noise_taps;   <span class="comment">% state dimension 10 for speech state + length of colored noise state</span>
0064   model.obsdim     = 1;                 <span class="comment">% observation dimension</span>
0065   model.paramdim   = speech_taps + noise_taps;   <span class="comment">% parameter dimension  (weights + colored noise parameters)</span>
0066   model.U1dim      = 0;                 <span class="comment">% exogenous control input 1 dimension</span>
0067   model.U2dim      = 0;                 <span class="comment">% exogenous control input 2 dimension</span>
0068   model.Vdim       = 2;                 <span class="comment">% process noise dimension  (augmented process noise needed for colored noise,</span>
0069                                         <span class="comment">% resulting in perfect measurment model with no explicit observation noise</span>
0070   model.Ndim       = 0;                 <span class="comment">% observation noise dimension (efective noise dimension is 0 for colored noise case)</span>
0071 
0072   <span class="comment">%-- SETUP NOISE DATA STRUCTURES</span>
0073 
0074   Arg.type = <span class="string">'gaussian'</span>;                <span class="comment">% process noise source</span>
0075   Arg.cov_type = <span class="string">'full'</span>;
0076   Arg.dim = model.Vdim;
0077   Arg.mu = [0; 0];
0078   Arg.cov  = [speech_pnvar 0; 0 noise_pnvar];        <span class="comment">% process noise variance</span>
0079   model.pNoise = <a href="../../.././ReBEL-0.2.7/core/gennoiseds.html" class="code" title="function NoiseDS = gennoiseds(ArgDS)">gennoiseds</a>(Arg);       <span class="comment">% generate process noise data structure : zero mean white Gaussian noise</span>
0080 
0081   Arg.type = <span class="string">'gaussian'</span>;
0082   Arg.dim = 0;
0083   Arg.mu = [];
0084   Arg.cov  = [];
0085   model.oNoise = <a href="../../.././ReBEL-0.2.7/core/gennoiseds.html" class="code" title="function NoiseDS = gennoiseds(ArgDS)">gennoiseds</a>(Arg);     <span class="comment">% This observation noise model is actually only a dummy model, in that for the colored</span>
0086                                       <span class="comment">% noise case, the observation noise enters the state observation function implicitely.</span>
0087 
0088 
0089   <span class="comment">%-- OPTIONAL FIELDS</span>
0090 
0091   model.noise_model = noise_model(:)';    <span class="comment">% AR model for colored noise</span>
0092   model.speech_model = speech_model(:)';
0093   model.speech_taps = speech_taps;
0094   model.noise_taps = noise_taps;
0095 
0096   <span class="comment">%-- Call 'setparams' function once to make sure model parameters are correctly initialized</span>
0097 
0098   model = <a href="#_sub2" class="code" title="subfunction model = setparams(model, params, index_vector)">setparams</a>(model, [speech_model(:); noise_model(:)]);    <span class="comment">% set/store the model parameters</span>
0099 
0100 
0101 <span class="comment">%===============================================================================================</span>
0102 <a name="_sub2" href="#_subfunctions" class="code">function model = setparams(model, params, index_vector)</a>
0103 
0104   <span class="keyword">if</span> (nargin==2)
0105     model.params = params(:);
0106   <span class="keyword">elseif</span> (nargin==3)
0107     model.params(index_vector) = params(:);
0108   <span class="keyword">else</span>
0109     error(<span class="string">'[ setparams ] Incorrect number of input arguments.'</span>);
0110   <span class="keyword">end</span>
0111 
0112   model.speech_model = model.params(1:model.speech_taps)';
0113   model.noise_model = model.params(model.speech_taps+1:end)';
0114 
0115 
0116 <span class="comment">%===============================================================================================</span>
0117 <a name="_sub3" href="#_subfunctions" class="code">function new_state = ffun(model, state, V, U1)</a>
0118 
0119   [dim,N] = size(state);
0120 
0121   speech_taps = model.speech_taps;
0122 
0123   new_state = zeros(dim,N);
0124 
0125   <span class="comment">%-- SPEECH STATE UPDATE          -  linear AR</span>
0126   new_state(1,:) = model.speech_model*state(1:speech_taps,:);
0127   new_state(2:speech_taps,:) = state(1:speech_taps-1,:);
0128 
0129   <span class="comment">%-- COLORED NOISE STATE UPDATE   -  linear AR</span>
0130   new_state(speech_taps+1,:) = model.noise_model*state(speech_taps+1:<span class="keyword">end</span>,:);
0131   new_state(speech_taps+2:<span class="keyword">end</span>,:) = state(speech_taps+1:end-1,:);
0132 
0133   <span class="keyword">if</span> ~isempty(V)
0134     new_state(1,:) = new_state(1,:) + V(1,:);
0135     new_state(speech_taps+1,:) = new_state(speech_taps+1,:) + V(2,:);
0136   <span class="keyword">end</span>
0137 
0138 <span class="comment">%===============================================================================================</span>
0139 <a name="_sub4" href="#_subfunctions" class="code">function observ = hfun(model, state, N, U2)</a>
0140 
0141   <span class="keyword">if</span> isempty(N),
0142 
0143     observ = state(1,:) + state(model.speech_taps+1,:);
0144 
0145   <span class="keyword">else</span>
0146 
0147     observ = state(1,:) + state(model.speech_taps+1,:) + N(1,:);
0148 
0149   <span class="keyword">end</span>
0150 
0151 
0152 
0153 
0154 
0155</pre></div>
<hr><address>Generated on Tue 26-Sep-2006 10:36:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>